<?php
	defined( '_JEXEC' ) or die( 'Restricted access' );
	jimport( 'joomla.application.component.controller' );
	class ContratosControllerContrato extends JController
	{
		function __contruct( $config = array())
		{
			parent::__construct( $config );	
			$this->registerTask( 'add',			'edit' );
			$this->registerTask( 'apply',		'save' );
			$this->registerTask( 'resethits',	'save' );
			$this->registerTask( 'unpublish',	'publish' );
		}
		function display()
		{
			global $mainframe;
			$db =& JFactory::getDBO();
			$query = 'select * from #__contratos';
			$db->setQuery($query);
			$rows = $db->loadObjectList();
			require_once(JPATH_COMPONENT.DS.'views'.DS.'contrato.php');
			ContratosViewContrato::contratos( $rows );
		}
		function edit()
		{
			$db	=& JFactory::getDBO();
			if ($this->_task == 'edit') {
				$id	= JRequest::getVar('id', array(0), 'method', 'array');
				$id	= array((int) $id[0]);
			} else {
				$id	= array( 0 );
			}
	
			$option = JRequest::getCmd('option');
	
			$lists = array();
	
			$row =& JTable::getInstance('contratos', 'Table');
			$row->load( $id[0] );	
			require_once(JPATH_COMPONENT.DS.'views'.DS.'contrato.php');
			ContratosViewContrato::contrato( $row);
		}
	}
		
?>
